<template>
	<view class="navigation-box">
		<view class="back" @click="back"></view>
		<view class="title">
			{{navigationMsg.title}}
		</view>
	</view>
</template>

<script>
	import {
		http
	} from '@/api/index.js'
	export default {
		props: ["navigationMsg"],
		data() {
			return {
				//背景色
				bgColor: "#fff",
				//文本色
				textColor: "#2A2D2E"
			}
		},
		methods: {
			//获取网站配置
			getSetting() {
				http.post('/api/index/getSetting').then(res => {
					document.documentElement.style.setProperty('--bg-color', res.theme_color);
					document.documentElement.style.setProperty('--text-color', res.font_color);
				}).catch(err => {
					console.log(err);
				})
			},
			back() {
				// let canNavBack = getCurrentPages()
				// let token = uni.getStorageSync('token')
				// if (canNavBack && canNavBack.length > 1) {
				// 	if (!token && canNavBack[canNavBack.length - 1].route === 'pages/login/login') {
				// 		uni.navigateTo({
				// 			url: "/pages/index/index"
				// 		})
				// 	}
				// 	uni.navigateBack()
				// } else {
				// 	if (!token) {
				// 		uni.navigateTo({
				// 			url: "/pages/index/index"
				// 		})
				// 		return
				// 	}
				// 	history.back();
				// }
				let canNavBack = getCurrentPages()
				if (canNavBack && canNavBack.length > 1) {
					uni.navigateBack()
				} else {
					history.back();
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	:root {
		--bg-color: ;
		--text-color: ;
	}

	.navigation-box {
		width: 100%;
		height: 100rpx;
		position: relative;
		background-color: var(--bg-color);
		color: var(--text-color);

		.back {
			width: 45rpx;
			height: 45rpx;
			background-image: url("../static/leftArrow_black.svg");
			background-size: contain;
			background-position: center;
			background-repeat: no-repeat;
			position: absolute;
			top: calc(50% - 25rpx);
			left: 10rpx;
		}

		.title {
			width: 300rpx;
			height: 100rpx;
			line-height: 100rpx;
			font-weight: bold;
			font-size: 36rpx;
			text-align: center;
			position: absolute;
			top: 0;
			left: calc(50% - 150rpx);
		}
	}
</style>